package com.bmit.ava.mapper;

import com.bmit.ava.model.AvaCode;
import com.bmit.ava.model.AvaCodeExample;
import com.bmit.ava.model.AvaCodeWithBLOBs;

import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface AvaCodeMapper {
    @SelectProvider(type = AvaCodeSqlProvider.class, method = "countByExample")
    long countByExample(AvaCodeExample example);

    @DeleteProvider(type = AvaCodeSqlProvider.class, method = "deleteByExample")
    int deleteByExample(AvaCodeExample example);

    @Delete({
            "delete from ava_code",
            "where code_id = #{codeId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer codeId);

    @Insert({
            "insert into ava_code (code_id, last_update_date, ",
            "title, labels, version, ",
            "resume, code)",
            "values (#{codeId,jdbcType=INTEGER}, #{lastUpdateDate,jdbcType=VARCHAR}, ",
            "#{title,jdbcType=VARCHAR}, #{labels,jdbcType=VARCHAR}, #{version,jdbcType=INTEGER}, ",
            "#{resume,jdbcType=LONGVARCHAR}, #{code,jdbcType=LONGVARCHAR})"
    })
    int insert(AvaCodeWithBLOBs record);

    @InsertProvider(type = AvaCodeSqlProvider.class, method = "insertSelective")
    int insertSelective(AvaCodeWithBLOBs record);

    @SelectProvider(type = AvaCodeSqlProvider.class, method = "selectByExampleWithBLOBs")
    @Results({
            @Result(column = "code_id", property = "codeId", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "last_update_date", property = "lastUpdateDate", jdbcType = JdbcType.VARCHAR),
            @Result(column = "title", property = "title", jdbcType = JdbcType.VARCHAR),
            @Result(column = "labels", property = "labels", jdbcType = JdbcType.VARCHAR),
            @Result(column = "version", property = "version", jdbcType = JdbcType.INTEGER),
            @Result(column = "resume", property = "resume", jdbcType = JdbcType.LONGVARCHAR),
            @Result(column = "code", property = "code", jdbcType = JdbcType.LONGVARCHAR)
    })
    List<AvaCodeWithBLOBs> selectByExampleWithBLOBs(AvaCodeExample example);

    @SelectProvider(type = AvaCodeSqlProvider.class, method = "selectByExample")
    @Results({
            @Result(column = "code_id", property = "codeId", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "last_update_date", property = "lastUpdateDate", jdbcType = JdbcType.VARCHAR),
            @Result(column = "title", property = "title", jdbcType = JdbcType.VARCHAR),
            @Result(column = "labels", property = "labels", jdbcType = JdbcType.VARCHAR),
            @Result(column = "version", property = "version", jdbcType = JdbcType.INTEGER)
    })
    List<AvaCode> selectByExample(AvaCodeExample example);

    @Select({
            "select",
            "code_id, last_update_date, title, labels, version, resume, code",
            "from ava_code",
            "where code_id = #{codeId,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column = "code_id", property = "codeId", jdbcType = JdbcType.INTEGER, id = true),
            @Result(column = "last_update_date", property = "lastUpdateDate", jdbcType = JdbcType.VARCHAR),
            @Result(column = "title", property = "title", jdbcType = JdbcType.VARCHAR),
            @Result(column = "labels", property = "labels", jdbcType = JdbcType.VARCHAR),
            @Result(column = "version", property = "version", jdbcType = JdbcType.INTEGER),
            @Result(column = "resume", property = "resume", jdbcType = JdbcType.LONGVARCHAR),
            @Result(column = "code", property = "code", jdbcType = JdbcType.LONGVARCHAR)
    })
    AvaCodeWithBLOBs selectByPrimaryKey(Integer codeId);

    @UpdateProvider(type = AvaCodeSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") AvaCodeWithBLOBs record, @Param("example") AvaCodeExample example);

    @UpdateProvider(type = AvaCodeSqlProvider.class, method = "updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") AvaCodeWithBLOBs record, @Param("example") AvaCodeExample example);

    @UpdateProvider(type = AvaCodeSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") AvaCode record, @Param("example") AvaCodeExample example);

    @UpdateProvider(type = AvaCodeSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(AvaCodeWithBLOBs record);

    @Update({
            "update ava_code",
            "set last_update_date = #{lastUpdateDate,jdbcType=VARCHAR},",
            "title = #{title,jdbcType=VARCHAR},",
            "labels = #{labels,jdbcType=VARCHAR},",
            "version = #{version,jdbcType=INTEGER},",
            "resume = #{resume,jdbcType=LONGVARCHAR},",
            "code = #{code,jdbcType=LONGVARCHAR}",
            "where code_id = #{codeId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(AvaCodeWithBLOBs record);

    @Update({
            "update ava_code",
            "set last_update_date = #{lastUpdateDate,jdbcType=VARCHAR},",
            "title = #{title,jdbcType=VARCHAR},",
            "labels = #{labels,jdbcType=VARCHAR},",
            "version = #{version,jdbcType=INTEGER}",
            "where code_id = #{codeId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(AvaCode record);
}